import * as dotenv from 'dotenv'
import { getSK } from "./util/sec";
import { verify } from 'crypto';
dotenv.config()

interface Config {
  port: number
  appid: string
  appkey: string
  host: string
  companyId: string
  platformId: string
  oauth: {
    clientId: string
    clientSecret: string
    loginUrl: string
    tokenUrl: string
    userInfoUrl: string
    wpsHomeUrl: string
    privateKey: string
    verify: string
  }
  redis: {
    password: string

  }
  mysql: {
    host: string,
    port: number,
    username: string,
    password: string,
    database: string
  }
}

const config: Config = {
  port: process.env.HTTP_KPORT ? parseInt(process.env.HTTP_KPORT) : 8000,
  appid: process.env.AK,
  appkey: getSK(),
  host: process.env.HOST,
  companyId: process.env.COMPANY_ID || '1',
  platformId: process.env.PLATFORM_ID || '1',
  oauth: {
    clientId: process.env.OAUTH_CLIENTID,
    clientSecret: process.env.OAUTH_CLIENTSECRET,
    loginUrl: process.env.OAUTH_LOGIN_URL,
    tokenUrl: process.env.OAUTH_TOKEN_URL,
    userInfoUrl: process.env.OAUTH_USERINFO_URL,
    wpsHomeUrl: process.env.OAUTH_WPS_HOME_URL,
    privateKey: process.env.OAUTH_PRIVATE_KEY,
    verify: process.env.OAUTH_VERIFY_URL
  },
  redis: {
    password: process.env.REDIS_PASSWORD
  },
  mysql: {
    host: process.env.MYSQL_HOST,
    port: parseInt(process.env.MYSQL_PORT),
    username: process.env.MYSQL_USER,
    password: process.env.MYSQL_PASSWORD,
    database: process.env.MYSQL_DATABASE
  }
}

export default config
